package System;
//使用引用数据类型
public class arrcopytext2 {
    public static void main(String[] args) {
        Student[] arr = new Student[3];
        arr[0] = new Student(18,"张三");
        arr[1] = new Student(16,"李四");
        arr[2] = new Student(20,"王五");
        Student[] arr1 = new Student[3];
        person[] arr3 = new person[3];

        System.arraycopy(arr,0,arr1,0,3);
        System.arraycopy(arr,0,arr3,0,3);

        getStudent(arr);
        System.out.println("------------------------");
        getStudent(arr1);
        System.out.println("------------------------");
        getStudent(arr3);

    }
//使用person的原因是父类形参可接受子类形参
    private static void getStudent(person[] arr) {
        for (int i = 0; i < arr.length; i++) {
            person stu = arr[i];
//            Student stu = (Student) arr[i];//与上一句同效
            System.out.println("年龄："+stu.getAge()+"  姓名:"+stu.getName());
        }
    }
}
